const Core = require('@alicloud/pop-core');
require('dotenv').config(); //默认.env在同一目录

// 阿里云客户端配置
const client = new Core({
    accessKeyId: process.env.ALIYUN_IHEALTHIFY_ACCESS_KEY_ID,
    accessKeySecret: process.env.ALIYUN_IHEALTHIFY_ACCESS_KEY_SECRET,
    endpoint: 'https://alidns.aliyuncs.com',
    apiVersion: '2015-01-09'
});

async function addDnsRecord(params = { DomainName: 'smartbiome.cn', RR: '*', Type: 'A', Value: '47.95.204.75' }) {

    try {
        const result = await client.request('AddDomainRecord', params, { method: 'POST' });
        console.log('DNS记录添加成功，RecordID:', result.RecordId);
    } catch (error) {
        console.error('错误详情:', {
            code: error.code,
            message: error.data?.Message || error.message
        });
    }
}

async function main() {
    await addDnsRecord();
}

main();
